This section gives details on the functions that the panel component must provide so that the sequence grabber can load the component's items into the settings dialog box and receive and process dialog events.
Listing 7-2 provides an example of the management of the settings dialog box for a sequence grabber that displays PICT images. The component item displayed in the dialog box in this case is a tick count checkbox.
Listing 2 Managing the settings dialog box
pascal ComponentResult PictPanelPanelGetDitl
(PictPanelGlobals store,
Handle *ditl)
{
/*
Get and detach the dialog box template. Note that
the sequence grabber has already opened the resource file.
*/
*ditl = GetResource ('DITL', 7001);
if (!*ditl) return resNotFound;
DetachResource (*ditl);
return noErr;
}
pascal ComponentResult PictPanelPanelInstall
(PictPanelGlobals store, SGChannel c,
DialogPtr d, short itemOffset)
{
Rect r;
short kind;
Handle h;
Boolean ticksShowing;
/* set up the initial state of the checkbox */
GetDItem (d, 1 + itemOffset, &kind, &h, &r);
store->ch = (ControlHandle)h;
SGGetShowTickCount (c, &ticksShowing);
SetCtlValue (store->ch, ticksShowing);
return noErr;
}
pascal ComponentResult PictPanelPanelItem
(PictPanelGlobals store, SGChannel c,
DialogPtr d, short itemOffset,
short itemNum)
{
/* if the item clicked was your checkbox, update its state */
if ((itemNum - itemOffset) == 1) {
Boolean showing = GetCtlValue (store->ch);
SetCtlValue (store->ch, !showing);
SGSetShowTickCount (c, !showing);
}
return noErr;
}
pascal ComponentResult PictPanelPanelRemove
(PictPanelGlobals store,
SGChannel c, DialogPtr d,
short itemOffset)
{
/* forget that it ever had a control */
store->ch = nil;
return noErr;
}